<!DOCTYPE html>
<html>

<head>
    <include file="public@head" title="单页管理" keywords="后台管理系统"/>
</head>

<body class="layui-layout-admin">
<include file="public@header"/>
<include file="public@side"/>

<div class="layui-body">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a href="{:url('admin/index/index')}">主页</a>
        <a>内容管理</a>
        <a href="{:url('admin/page/index')}">单页管理</a>
        <a><cite>编辑单页</cite></a>
    </div>
    <div class="layui-fluid">
        <div class="layui-card layui-row">
            <div class="layui-card-header">
                编辑单页
            </div>
            <div class="layui-card-body">
                <form action="{:url('admin/page/edit')}" method="post" class="layui-form pdt10">
                    <div class="layui-col-md9">
                        <div class="layui-form-item">
                            <label class="layui-form-label">标题<span class="form-required">*</span></label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" name="title" value="{$page.title}"
                                       lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">关键词</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" value="{$page.keywords}" name="keywords">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">摘要</label>
                            <div class="layui-input-block">
                                <textarea class="layui-textarea" name="excerpt">{$page.excerpt}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">正文<span class="form-required">*</span></label>
                            <div class="layui-input-block">
                                <textarea type="text/plain" id="editor" style="width:100%;height:250px;" name="content">{$page.content}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="hidden" name="id" value="{$page.id}"/>
                                <button type="submit" class="layui-btn" lay-submit lay-filter="general">保存修改</button>
                                <a class="layui-btn layui-btn-primary" href="javascript:history.back(-1);">返回</a>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item">
                            <label class="layui-form-label">缩略图</label>
                            <div class="layui-input-block">
                                <a id="btn-thumb">
                                    <empty name="post.thumb">
                                        <img src="__STATIC__/images/default-thumb.png" id="thumb-preview" width="135"
                                             height="135" style="cursor: pointer"/>
                                        <else/>
                                        <img src="{:get_image_url($page['thumb'])}" id="thumb-preview" width="135"
                                             height="135" style="cursor: pointer"/>
                                    </empty>
                                </a>
                                <div id="tips-thumb"></div>
                                <input type="hidden" name="thumb" id="input-thumb" value="{$page.thumb}">
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<include file="public@scripts"/>
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.js"></script>
<script>
    UE.getEditor("editor");

    var upload = layui.upload;

    upload.render({
        elem: '#btn-thumb',
        url: "{:url('api/asset/fileUpload')}",
        size: 200,
        exts: 'jpg|png|bmp|jpeg',
        data: {path: 'page'},
        before: function (obj) {
            obj.preview(function (index, file, result) {
                $('#thumb-preview').attr('src', result); //图片链接（base64）
            });
        },
        done: function (res) {
            if (res.code == 0) {
                return layer.msg(res.message);
            }
            $('#input-thumb').val(res.filepath);
        }
    });
</script>
</body>

</html>
